import request from '@/config/axios'

export interface Model {
  id: string
  code: string
  config: string
  remark: string
  feeRate: number
  merchantId: string
  appId: string
  createTime: Date
}

// 查询列表支付渠道
export const getPage = (params: PageParam) => {
  return request.get({ url: import.meta.env.VITE_BASE_ROLE + '/pay/channel/page.json', params })
}

// 查询详情支付渠道
export const getChannel = (merchantId: string, appId: string, code: string) => {
  const params = {
    merchantId: merchantId,
    appId: appId,
    code: code
  }
  return request.get({
    url: import.meta.env.VITE_BASE_ROLE + '/pay/channel/get-channel',
    params: params
  })
}

// 修改支付渠道
export const update = (data: Model) => {
  return request.put({ url: import.meta.env.VITE_BASE_ROLE + '/pay/channel/update.json', data })
}

// 删除支付渠道
export const del = (id: string) => {
  return request.delete({ url: import.meta.env.VITE_BASE_ROLE + '/pay/channel/del.json?id=' + id })
}
